//
//  BCShopDetailCell.m
//  BangcaiBuy
//
//  Created by lsy on 16/6/20.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCShopDetailCell.h"

@interface BCShopDetailCell ()
{
    UIImageView *stuffImgView;
    UILabel *nameLab;
    UILabel *priceLab;
    UILabel *amountLab;
    UIView *backView;

}

@end

@implementation BCShopDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView
{
    stuffImgView = [[UIImageView alloc] init];
    nameLab = [[UILabel alloc] init];
    priceLab = [[UILabel alloc] init];
    priceLab.textColor = [UIColor colorWithRed:0.998  green:0.398  blue:0 alpha:1];
    priceLab.textAlignment = NSTextAlignmentRight;
    priceLab.font = [UIFont systemFontOfSize:16];
    self.checkBox = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.checkBox setImage:[UIImage imageNamed:@"未选择"] forState:UIControlStateNormal];
    [self.checkBox setImage:[UIImage imageNamed:@"选中"] forState:UIControlStateSelected];

    
    amountLab = [[UILabel alloc] init];
    amountLab.font = [UIFont systemFontOfSize:16];
    amountLab.textAlignment = NSTextAlignmentCenter;
    
    self.star = [[BCStarScoreView alloc] initWithFrame:CGRectMake(123, 30, 100, 20)];
    self.star.backgroundColor = [UIColor lightGrayColor];
    backView = [[UIView alloc] init];
    [backView addSubview:stuffImgView];
    [backView addSubview:nameLab];
    [backView addSubview:self.star];
    [backView addSubview:priceLab];
    [backView addSubview:amountLab];
    [backView addSubview:self.checkBox];
    backView.backgroundColor = [UIColor whiteColor];

    
    [self.contentView addSubview:backView];
     stuffImgView.backgroundColor = [UIColor blackColor];
    
}


- (void)layoutSubviews
{
    self.contentView.backgroundColor = [UIColor colorWithRed:0.972  green:0.973  blue:0.972 alpha:1];
   

    stuffImgView.image = _shopImg;
    nameLab.text = _shopName;
    priceLab.text = [NSString stringWithFormat:@"¥ %.2f", _price];
    
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.left.and.right.equalTo(self.contentView);
        make.bottom.mas_equalTo(-10);
        
    }];
    [self.checkBox mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.and.height.mas_equalTo(25);
        make.left.mas_equalTo(12);
        make.centerY.mas_equalTo(0);
    }];

    [stuffImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.and.width.mas_equalTo(50);
        make.top.equalTo(backView).with.offset(12);
        make.left.mas_equalTo(self.checkBox.mas_right).with.offset(12);
    }];
    
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(stuffImgView.mas_top);
        make.left.mas_equalTo(stuffImgView.mas_right).with.offset(12);
        make.height.mas_equalTo(26 );
        make.width.mas_equalTo(150 * wx);
    }];
    
    [self.star mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(nameLab.mas_bottom).with.offset(12);
        make.size.equalTo(nameLab);
        make.left.equalTo(nameLab);
        
    }];
    
    [priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.bottom.mas_equalTo(-12);
        make.width.mas_equalTo(80 * wx);
    }];
    
    [amountLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12 * wx);
        make.bottom.mas_equalTo(-12);
        make.width.and.height.mas_equalTo(30 * wx);
    }];
    
}


@end
